package com.wangmeng.book.utils;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;

/**
 * User: 王猛
 * Date: 13-9-23
 */
public class JSUtils implements Serializable {
    private static String JS_CONTENT = "";

    static {
        InputStream in = JSUtils.class.getClassLoader().getResourceAsStream("encode.js");
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        byte[] buffer = new byte[4096];
        int len = 0;
        try {
            while ((len = in.read(buffer)) > 0) {
                bout.write(buffer, 0, len);
            }
            if (bout.size() > 0) {
                JS_CONTENT = new String(bout.toByteArray(), "UTF-8");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static String getScript() {
        return JS_CONTENT;
    }
}